package io.github.talelin.latticy.controller.v1;


import io.github.talelin.latticy.dto.rule.chargeDataItem.ChargeDataItemDTO;
import io.github.talelin.latticy.service.ChargeDataItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.github.talelin.latticy.model.ChargeDataItemDO;
import io.github.talelin.latticy.vo.CreatedVO;
import io.github.talelin.latticy.vo.DeletedVO;
import io.github.talelin.latticy.vo.PageResponseVO;
import io.github.talelin.latticy.vo.UpdatedVO;

import javax.validation.constraints.Min;
import javax.validation.constraints.Max;
import javax.validation.constraints.Positive;

/**
 * 计费数据项前端控制器
 *
 * @author generator@wulongbo
 * @since 2022-08-26
 */
@RestController
@RequestMapping("/v1/chargeDataItem")
public class ChargeDataItemController {

    @Autowired
    private ChargeDataItemService chargeDataItemService;

    @PostMapping("")
    public CreatedVO create(@RequestBody @Validated ChargeDataItemDTO dto) {
        chargeDataItemService.addChargeDataItem(dto);
        return new CreatedVO();
    }

    @PutMapping("/{id}")
    public UpdatedVO update(@PathVariable @Positive(message = "{id.positive}") Integer id) {
        return new UpdatedVO();
    }

    @DeleteMapping("/{id}")
    public DeletedVO delete(@PathVariable @Positive(message = "{id.positive}") Integer id) {
        return new DeletedVO();
    }

    @GetMapping("/{id}")
    public ChargeDataItemDO get(@PathVariable(value = "id") @Positive(message = "{id.positive}") Integer id) {
        return null;
    }

    @GetMapping("/page")
    public PageResponseVO<ChargeDataItemDO> page(
            @RequestParam(name = "page", required = false, defaultValue = "0")
            @Min(value = 0, message = "{page.number.min}") Integer page,
            @RequestParam(name = "count", required = false, defaultValue = "10")
            @Min(value = 1, message = "{page.count.min}")
            @Max(value = 30, message = "{page.count.max}") Integer count
    ) {
        return null;
    }

}
